﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils;

public partial class order_success : FBasePage
{
    // Fields

    public Maticsoft.BLL.orderdetail detailbll = new Maticsoft.BLL.orderdetail();
    public List<Maticsoft.Model.orderdetail> detaillist = new List<Maticsoft.Model.orderdetail>();
    public Maticsoft.BLL.Order orderbll = new Maticsoft.BLL.Order();
    public Maticsoft.Model.Order ordermodel = new Maticsoft.Model.Order();
    public string teamid;
    protected int type = 0;
    public Maticsoft.BLL.UserInfo userbll = new Maticsoft.BLL.UserInfo();
    public Maticsoft.Model.UserInfo usermodel = new Maticsoft.Model.UserInfo();

    // Methods
    public void Getorder(string orderid)
    {
        this.usermodel = this.userbll.Getusername(base.UserName);
        this.ordermodel = this.orderbll.GetModel(Convert.ToInt32(this.hidorderid.Value));
        string str = this.ordermodel.Pay_id;
        this.teamid = this.ordermodel.Team_id.ToString();
    }

    public string GetTeam(string id, int orderid)
    {
        string str = "";
        Maticsoft.Model.Team model = new Maticsoft.Model.Team();
        Maticsoft.BLL.Team team2 = new Maticsoft.BLL.Team();
        model = team2.GetModel(Convert.ToInt32(id));
        if (model != null)
        {
            return string.Concat(new object[] { "<a href='/team.aspx?id=", model.Id, "'>", model.Title, "</a>" });
        }
        this.detaillist = this.detailbll.Searchorderdetail(orderid);
        if (this.detaillist != null)
        {
            int num = 0;
            foreach (Maticsoft.Model.orderdetail orderdetail in this.detaillist)
            {
                num++;
                object obj2 = str;
                str = string.Concat(new object[] { obj2, "<u><a href='/team.aspx?id=", orderdetail.Teamid, "'>", num, ":" });
                str = str + ((team2.GetModel(Convert.ToInt32(orderdetail.Teamid)) == null) ? "" : team2.GetModel(Convert.ToInt32(orderdetail.Teamid)).Title);
                str = str + "</a><br></u>";
            }
            return str;
        }
        return "";
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        string id = Helper.GetString(base.Request["id"], string.Empty);
        if (id != string.Empty)
        {
            Maticsoft.Model.Pay model = new Maticsoft.BLL.Pay().GetModel(id);
            if (model != null)
            {
                if (model.Order_id > 0)
                {
                    this.hidorderid.Value = model.Order_id.ToString();
                    this.Getorder(model.Order_id.ToString());
                    this.type = 1;
                }
                else
                {
                    this.type = 2;
                }
            }
        }
    }

}